﻿using System;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;

namespace DataUpload
{
    public partial class MainForm : Form
    {
        internal FrmConnect frmConnect = null;
        internal FrmAddFiles frmAddFiles = null;
        internal FrmBaseFormat frmBaseFormat = null;
        internal FrmMapping frmMapping = null;
        //internal FrmCommonOptions frmCommonOptions = null;
        //internal FrmReview frmReview = null;
        internal FrmProgress frmProgress = null;
        internal FrmSummary frmSummary = null;
        internal ImageList imgList = null;
        //internal Process myProcess;
        //internal Thread mainThread;
        //private System.Windows.Forms.Timer _myTimer;

        public MainForm()
        {
            InitializeComponent();
            imgList = new ImageList();
            imgList.ColorDepth = ColorDepth.Depth32Bit;

            //myProcess = Process.GetCurrentProcess();
            //mainThread = Thread.CurrentThread;
            //_myTimer = new System.Windows.Forms.Timer();
            //_myTimer.Interval = 3000;
            //_myTimer.Tick += new EventHandler(_myTimer_Tick);
            //_myTimer.Start();
        }

        //private void _myTimer_Tick(object sender, EventArgs e)
        //{
        //    Application.DoEvents();

        //    if (!myProcess.Responding)
        //        _myTimer.Interval = 50;
        //    else
        //        _myTimer.Interval = 5000;
        //}

        private void MainForm_Shown(object sender, EventArgs e)
        {
            this.Hide();
            frmConnect = new FrmConnect(this);
            frmConnect.Show();
        }

        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            //_myTimer.Stop();

            if (frmConnect != null)
                frmConnect.Close();
            if (frmAddFiles != null)
                frmAddFiles.Close();
            if (frmBaseFormat != null)
                frmBaseFormat.Close();
            if (frmMapping != null)
                frmMapping.Close();
            //if (frmCommonOptions != null)
            //    frmCommonOptions.Close();
            //if (frmReview != null)
            //    frmReview.Close();
            if (frmProgress != null)
                frmProgress.Close();
            if (frmSummary != null)
                frmSummary.Close();
            if (imgList != null)
                imgList.Dispose();

            //_myTimer.Dispose();
        }
    }
}
